package com.lb.objectmapper;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.time.LocalDateTime;

/**
 * @version 1.0
 * @Author: Edward
 * @Date: 2021/4/19 17:27
 * @Description:
 */
public class UserTest {
    public static void main(String[] args) throws JsonProcessingException {
        User u = new User();
        u.setBirthday(LocalDateTime.now());
        String jsonString = JSON.toJSONString(u);
        System.out.println(jsonString);

        ObjectMapper mapper = new ObjectMapper();
//        User u1 = mapper.readValue(jsonString, User.class);
//        System.out.println(u1);


        String reqJson = mapper.writeValueAsString(u);
        System.out.println(reqJson);

        User u2 = JSON.parseObject(reqJson, User.class);
        System.out.println(u2);
    }
}
